import { createRouter, createWebHashHistory } from 'vue-router';
import Home from '../views/Home.vue';
import Dashboard from '../views/Dashboard.vue';
import UserProfile from '../views/UserProfile.vue';

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    meta: {
      title: '首页',
      icon: '🏠'
    }
  },
  {
    path: '/dashboard',
    name: 'Dashboard',
    component: Dashboard,
    meta: {
      title: '仪表板',
      icon: '📊'
    }
  },
  {
    path: '/user-profile',
    name: 'UserProfile',
    component: UserProfile,
    meta: {
      title: '用户资料',
      icon: '👤'
    }
  }
];

const router = createRouter({
  // 使用 hash 模式，避免在扩展环境中的路径问题
  history: createWebHashHistory(),
  routes
});

// 路由守卫：更新页面标题
router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = `${to.meta.title} - WXT 扩展`;
  }
  next();
});

export default router; 